//
//  studentDetialView.m
//  jiaKaoZhuShou
//
//  Created by 金艺社 on 2018/5/22.
//  Copyright © 2018年 金艺社. All rights reserved.
//

#import "studentDetialView.h"
@implementation studentDetialView

- (instancetype)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        self.backgroundColor = [UIColor whiteColor];
        [self addSubview:self.head_ImagV];
        [self addSubview:self.name_lab];
        [self addSubview:self.sex_lab];
        [self addSubview:self.realName_lab];
        [self addSubview:self.age_lab];
        [self addSubview:self.success_lab];
        [self addSubview:self.points_lab];
        [self addSubview:self.message_btn];
        [self addSubview:self.phone_btn];
        [self addSubview:self.starView];
        [self layoutSubview];
    }
    return self;
}

- (void)layoutSubview {
    [self.head_ImagV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.top.equalTo(self).offset(10);
//        make.width.height.equalTo(@30);
    }];
    [self.name_lab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.head_ImagV.mas_top);
        make.left.equalTo(self.head_ImagV.mas_right).offset(3);
//        make.width.equalTo(@85);
//        make.height.equalTo(@25);
    }];
    [self.sex_lab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.name_lab.mas_centerY);
        make.left.equalTo(self.name_lab.mas_right).offset(3);
        make.width.equalTo(@20);
        make.height.equalTo(@25);
    }];
    [self.realName_lab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.name_lab.mas_centerY);
        make.left.equalTo(self.sex_lab.mas_right);
        make.width.equalTo(@50);
        make.height.equalTo(@15);
    }];
    [self.age_lab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.name_lab.mas_bottom).offset(3);
        make.left.equalTo(self.name_lab.mas_left);
        make.width.equalTo(@85);
        make.height.equalTo(@25);
    }];
    [self.success_lab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.age_lab.mas_bottom).offset(3);
        make.left.equalTo(self.name_lab.mas_left);
        make.width.equalTo(@100);
        make.height.equalTo(@25);
    }];
    [self.points_lab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.age_lab.mas_bottom).offset(3);
        make.left.equalTo(self.name_lab.mas_left);
//        make.width.equalTo(@50);
//        make.height.equalTo(@25);
    }];
    [self.starView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.points_lab.mas_right).offset(3);
        make.centerY.equalTo(self.points_lab.mas_centerY);
        make.width.equalTo(@100);
        make.height.equalTo(@15);
    }];
    [self.message_btn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.mas_centerY);
        make.right.equalTo(self.mas_right).offset(-10);
        make.width.height.equalTo(@50);
    }];
    [self.phone_btn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.age_lab.mas_centerY);
        make.right.equalTo(self.mas_right).offset(-10);
        make.width.height.equalTo(@25);
    }];
}

#pragma mark --- getter
- (UILabel *)name_lab {
    if (!_name_lab) {
        _name_lab = [UILabel new];
        _name_lab.text = @"张无忌";
        _name_lab.textColor = [UIColor custom_color:@"#333333"];
        _name_lab.font = [UIFont customFontOfSize:15];
    }
    return _name_lab;
}
- (UILabel *)age_lab {
    if (!_age_lab) {
        _age_lab = [UILabel new];
        _age_lab.text = @"驾龄:15年";
        _age_lab.textColor = [UIColor custom_color:@"#666666"];
        _age_lab.font = [UIFont customFontOfSize:12];
    }
    return _age_lab;
}
- (UILabel *)success_lab {
    if (!_success_lab) {
        _success_lab = [UILabel new];
        _success_lab.hidden = YES;
        _success_lab.text = @"通过率:98%";
        _success_lab.textColor = [UIColor custom_color:@"#666666"];
        _success_lab.font = [UIFont customFontOfSize:12];
    }
    return _success_lab;
}
- (UILabel *)points_lab {
    if (!_points_lab) {
        _points_lab = [UILabel new];
        _points_lab.text = @"综合评分:";
        _points_lab.textColor = [UIColor custom_color:@"#666666"];
        _points_lab.font = [UIFont customFontOfSize:12];
    }
    return _points_lab;
}
- (UILabel *)sex_lab {
    if (!_sex_lab) {
        _sex_lab = [UILabel new];
        _sex_lab.text = @"♂";
        _sex_lab.textColor = [UIColor custom_color:@"#4197F3"];
        _sex_lab.font = [UIFont customFontOfSize:12];
    }
    return _sex_lab;
}
- (UILabel *)realName_lab {
    if (!_realName_lab) {
        _realName_lab = [UILabel new];
        _realName_lab.backgroundColor = [UIColor custom_color:@"#DF7074"];
        _realName_lab.layer.masksToBounds = YES;
        _realName_lab.layer.cornerRadius = 3;
        _realName_lab.text = @"实名认证";
        _realName_lab.textAlignment = NSTextAlignmentCenter;
        _realName_lab.textColor = [UIColor whiteColor];
        _realName_lab.font = [UIFont customFontOfSize:9];
    }
    return _realName_lab;
}
- (UIImageView *)head_ImagV {
    if (!_head_ImagV) {
        _head_ImagV = [UIImageView new];
    }
    return _head_ImagV;
}
- (UIButton *)phone_btn {
    if (!_phone_btn) {
        _phone_btn = [UIButton new];
        _phone_btn.layer.masksToBounds = YES;
        _phone_btn.layer.cornerRadius = 12.5;
        _phone_btn.layer.borderColor = [UIColor custom_color:@"#A91E23"].CGColor;
        _phone_btn.layer.borderWidth = 1;
        [_phone_btn setImage:[UIImage imageNamed:@"redPhone"] forState:0];
        [_phone_btn addTarget:self action:@selector(phoneClick) forControlEvents:UIControlEventTouchUpInside];
    }
    return _phone_btn;
}
- (UIButton *)message_btn {
    if (!_message_btn) {
        _message_btn = [UIButton new];
        _message_btn.hidden = YES;
        [_message_btn setImage:[UIImage imageNamed:@"redMessage"] forState:0];
        [_message_btn addTarget:self action:@selector(messageClick) forControlEvents:UIControlEventTouchUpInside];
    }
    return _message_btn;
}

- (UIView *)starView {
    if (!_starView) {
        _starView = [[startView alloc]initWithFrame:CGRectMake(0, 0, 100, 15)];
    }
    return _starView;
}

#pragma mark --- btnClick
- (void)phoneClick {
    if (![self.phone isEqualToString:@""]  && self.phone != nil) {
        NSString *callPhone = [NSString stringWithFormat:@"telprompt://%@", self.phone];
        if (@available(iOS 10.0, *)) {
            [[UIApplication sharedApplication] openURL:[NSURL URLWithString:callPhone] options:@{} completionHandler:nil];
        } else {
            [[UIApplication sharedApplication] openURL:[NSURL URLWithString:callPhone]];
        }
    }else {
        [MBProgressHUD gk_toastShowMessage:@"手机号不存在"];
    }
    
}

- (void)messageClick {
    
}




- (UIImageView *)sex_ImagV {
    if (!_sex_ImagV) {
        _sex_ImagV = [UIImageView new];
        _sex_ImagV.image = [UIImage imageNamed:@"♂"];
    }
    return _sex_ImagV;
}
@end
